<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
		<title>Tiled map service</title>
		<link rel="stylesheet" href="https://js.arcgis.com/3.17/esri/css/esri.css">
		<style>
			html,
			body,
			#map {
				height: 100%;
				width: 100%;
				margin: 0;
				padding: 0;
			}
		</style>
	<script>
			var href = window.document.location.href;
			var index = href.lastIndexOf("/js/") + 3;
			var jsPath =href.substring(0,index);
				var dojoConfig = {
					async: true,
					labsPath:"/ylly-forestry-resources-webapp/assets/libs",
					packages: [{
						name: "widget",
						location: jsPath+"/widget"
					},
					{
						name: "project",
						location: jsPath+"/project"
					}
					]
				};
		</script>
		<script src="http://192.168.6.18/arcgis_js_api/library/3.17/3.17/init.js"></script>
		<script>
			var map;
			require(["esri/map", "widget/task/IdentityTask","widget/edit/Edit","esri/Color","esri/graphic", "esri/symbols/SimpleFillSymbol","esri/renderers/SimpleRenderer","dojo/_base/array", "esri/layers/GraphicsLayer", "esri/layers/ArcGISTiledMapServiceLayer", "esri/layers/FeatureLayer", "esri/layers/ArcGISDynamicMapServiceLayer", "dojo/domReady!"],
				function(Map, IdentityTask,edits,Color,graphic,SimpleFillSymbol,SimpleRenderer,arrayUtils, GraphicsLayer, ArcGISTiledMapServiceLayer, FeatureLayer, ArcGISDynamicMapServiceLayer) {
					map = new Map("map", {
						zoom: 12
					});
					/* var tiled = new ArcGISTiledMapServiceLayer("https://mapserv.utah.gov/arcgis/rest/services/BaseMaps/Terrain/MapServer");
					   map.addLayer(tiled);*/
					var baseLayer = new ArcGISDynamicMapServiceLayer("http://192.168.6.18/arcgis/rest/services/ylly/yuyangxiaoban_cache/MapServer");
					map.addLayer(baseLayer);
					var teamsFL = new FeatureLayer("http://192.168.6.18/arcgis/rest/services/ylly/yuyangxiaoban_cache/MapServer/0", {
						  outFields: ["*"]
					});
					map.addLayers([teamsFL]);
          /**
           * map点击查询
           */
					map.on("click", function(evt) {
						
							var query = new IdentityTask({
								layers: "http://192.168.6.18/arcgis/rest/services/ylly/yuyangxiaoban_cache/MapServer",
								layerIds: [0],
								mapPoint: evt.mapPoint
							});
							//处理返回结果
							var deferred = query.excute();
							deferred.then(function(res) {
								  //清空临时图层
							   map.graphics.clear();
							   var fill = new SimpleFillSymbol();
							   arrayUtils.map(res, function(result) {
										var feature = result.feature;
										//引入样式
										var gra = new graphic(feature.geometry,fill);
										//map.infoWindow.setFeatures([feature]);
										//将查询出来的对象加入临时图层
										map.graphics.add(gra);
										
								})
							});
							
						})

				});
		</script>
	</head>

	<body>
		<div id="map"></div>
	</body>

</html>